Skip to content

fix(cold-store): tolerate torn trailing line in parse_jsonl - #80

Merged
zzylol merged 1 commit into
mainfrom
fix/cold-fallback-torn-trailing-line
May 5, 2026
Merged

zzylol merged 1 commit into
mainfrom
fix/cold-fallback-torn-trailing-line

Conversation

@zzylol

@zzylol zzylol commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Cold-fallback parse_jsonl now drops a malformed trailing line with a warn log when the blob has no terminating newline (the producer-mid-flush shape from design-sketch-db.md §5.2). Mid-file malformed lines still hard-error so real corruption surfaces.
  • Threads Option<&Path> through a new parse_jsonl_at helper so the warn log includes the file path + 200-char line preview. Existing parse_jsonl(bytes, start, end) callers (local_fs.rs) are unchanged.
  • Unblocks ASAPCollector PROGRESS.md "Outstanding follow-ups feat: vendor DataCollector's modified OTLP proto (PR A, Phase 1) #5" and the E0 cold-routed query family (PR fix(precompute): factory routes CountSketch[WithHeap] to CmsAccumulator #261 saw 34/300 replay queries time out at 10 s on sum(http_requests_total) because of this).

Test plan

  • New parse_jsonl_ignores_torn_trailing_line — 3 valid lines + partial 4th, asserts 3 records + no error.
  • New parse_jsonl_errors_on_mid_file_corruption — valid / not-json / valid (newline-terminated), asserts Malformed("line 2: …").
  • Existing parse_jsonl_filters_range, parse_jsonl_malformed_errs, prefix_shape, hour_prefixes_*, and all local_fs::tests::scan_* still green.
  • cargo test --release -p query_engine_rust --lib drivers::query::fallback::cold_store — 11 passed, 0 failed.
  • cargo clippy --release -p query_engine_rust --all-targets -- -D warnings — pre-existing failures in simple_engine.rs / count_sketch_accumulator.rs / otel.rs unchanged; no new lints introduced by this change.

🤖 Generated with Claude Code

Under concurrent producer write + reader scan (the e2e harness
shape), the cold-fallback reader saw a part-file whose final line
was a partial JSON record and errored the whole scan, manifesting
as 10 s cold-fallback timeouts on `sum(http_requests_total)` in
E0 (PR #261, 34/300 replay queries).

Tolerate the torn last line specifically: if a parse error hits
the *final* line *and* the blob has no terminating newline (the
producer-mid-flush shape per design-sketch-db.md §5.2), warn +
drop instead of failing the part. Mid-file parse errors still
hard-error — that signals real corruption, not a concurrent write.

Threads `Option<&Path>` through a new `parse_jsonl_at` helper so
the warn log includes the offending file + a 200-char line preview;
existing `parse_jsonl(bytes, start, end)` callers (`local_fs.rs`)
unchanged.

Pins both shapes in tests:
- parse_jsonl_ignores_torn_trailing_line
- parse_jsonl_errors_on_mid_file_corruption

Unblocks PROGRESS.md "Outstanding follow-ups #5" and the E0
exit-criterion (1) cold-routed query family.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit a39877f into main May 5, 2026
@zzylol
zzylol deleted the fix/cold-fallback-torn-trailing-line branch May 9, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant